/**
 * Copyright 2010-2025 The mTASK Project Authors. All Rights Reserved.
 * Licensed under the MIT License (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.gitee.com/lort/mTask/LICENSE.md
 * Author: luyunyi @luyunyi2019@outlook.com
 */

#ifndef __MTASKTIMER_H__
#define __MTASKTIMER_H__

#include <mTaskType.h>

#ifdef __cplusplus
extern "C"
{
#endif

typedef void (*mTimerCb_t)(void *arg1, void *arg2); 

typedef struct
{
    struct rb_node rbNode;
    uint64_t runtime;
    uint64_t expire;
    mTimerCb_t cb;
    void    *arg1;
    void    *arg2;
    /* data */
}mTimer_t;

//common functions
int mTaskInitTimer(mTimer_t *timer, mTimerCb_t cb, void *arg1, void *arg2);

//static timer functions
int mTaskStartStaticTimer(mTimer_t *timer, uint64_t expire, int reload);
int mTaskStopStaticTimer(mTimer_t *timer);
int mTaskStaticTimerPoll(void);

//dynamic timer functions
mTimer_t* mTaskCreatDynamicTimer(void);
int mTaskStartDynamicTimer(mTimer_t *timer, uint64_t expire, int reload);
int mTaskStopDynamicTimer(mTimer_t *timer);
int mTaskDynamicTimerPoll(void);

#ifdef __cplusplus
}
#endif


#endif /* MAIN_ELOOP_ELOOP_LOG_H_ */


